import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.RMISecurityManager;

import net.jini.lookup.entry.Name;
import net.jini.core.lookup.ServiceRegistrar;
import net.jini.core.lookup.ServiceItem;
import net.jini.core.discovery.LookupLocator;
import net.jini.core.entry.Entry;
import net.jini.core.lease.Lease;

public class SimpleCamera extends UnicastRemoteObject implements Camera {
		
	public byte[] 	getImage(String name) throws RemoteException {
		System.out.println("Simple camera: get image: " + name);
		return null;
	}
	
	public String[] getImageNames() throws RemoteException {
		System.out.println("Simple camera: get image names");
		return new String[]{"photo"};
	}
	
	public void 	removeImage(String name) throws RemoteException {
		System.out.println("Simple camera: remove image: " + name);
	}
	
	public SimpleCamera() throws RemoteException {
		super ();
	}
	
	public static void main (String[] args) {
		try {
			System.setSecurityManager (new RMISecurityManager ());
			
			ServiceItem serviceItem = new ServiceItem(null, new SimpleCamera(), null);

			LookupLocator lookup = new LookupLocator ("jini://localhost");
			ServiceRegistrar registrar  = lookup.getRegistrar();
			registrar.register(serviceItem, Lease.FOREVER);

			System.out.println("Simple camera online");

		} catch (Exception e)
		{
			e.printStackTrace();
		}
	}

} 